package com.hongye.house.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.house.entity.NewsHomeEntity;
import com.hongye.house.service.NewsHomeService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 咨询表
 *
 * @author lins
 * @email 695565697@qq.com
 * @date 2021-10-14 13:32:23
 */
@RestController
@RequestMapping("house/newshome")
public class NewsHomeController {
    @Autowired
    private NewsHomeService newsHomeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = newsHomeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{newsId}")
    public R info(@PathVariable("newsId") Integer newsId){
		NewsHomeEntity newsHome = newsHomeService.getById(newsId);

        return R.ok().put("newsHome", newsHome);
    }

    /*
    *  查询手机号
     */
    @RequestMapping("/findByNewsTitle")
    public R findByPhone(String newsTitle){
        List<NewsHomeEntity> list=newsHomeService.findByphone(newsTitle);
        return R.ok().put("list",list);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody NewsHomeEntity newsHome){
		newsHomeService.save(newsHome);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody NewsHomeEntity newsHome){
		newsHomeService.updateById(newsHome);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{newsId}")
    public R delete(@PathVariable("newsId") Integer newsId){
		newsHomeService.removeById(newsId);

        return R.ok();
    }

}
